package com.conversationboard.view;

import com.conversationboard.model.Substitution;
import com.conversationboard.model.Substitutions;
import com.conversationboard.site.Site;

public class WordSubstitutionsDisplay {

    public static String display() {
        
        Substitutions substitutions = Site.getSubstitutions();

        StringBuilder buffer = new StringBuilder();

        buffer.append("<table class='table'>");

        buffer.append("<tr class='header'>");
        buffer.append("<td class='cell'>Login ID</td>");
        buffer.append("<td class='cell'>IP Address</td>");
        buffer.append("<td class='cell'>Regular Expression</td>");
        buffer.append("<td class='cell'>Substitution</td>");
        buffer.append("<td class='cell'>Remove</td>");
        buffer.append("</tr>");

        for (Substitution substitution : substitutions.values()) {

            buffer.append("<tr class='row'>");

            buffer.append("<td class='cell'>" + substitution.getLoginId() + "</td>\n");
            buffer.append("<td class='cell'>" + substitution.getIpAddress() + "</td>\n");
            buffer.append("<td class='cell'>" + substitution.getRegularExpression() + "</td>\n");
            buffer.append("<td class='cell'>" + substitution.getSubstitution() + "</td>\n");
            buffer.append("<td class='cell'><input type='checkbox' name='checkbox' value='" + substitution.getId() + "'></input></td>\n");

            buffer.append("</tr>\n");

        }

        buffer.append("</table>");
        buffer.append("<p><input type=\"submit\" value=\"     OK     \" /><p>");

        return buffer.toString();

    }

}
